home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / gfa / gfa_util.arc / SEL_FIL.LST next >
Encoding:
File List  |  1991-06-11  |  3.5 KB  |  147 lines

  1. sel_files("A:\")
  2. PROCEDURE sel_files(p$)
  3.   '
  4.   '         ************   FILE SELECTOR V1.2   **************
  5.   '
  6.   '  This procedure when passed the drive path by parameter will allow the
  7.   ' user to select any number of files in that path with the mouse.
  8.   '
  9.   ' Requirements:
  10.   '   -  This procedure is only written for 80 column screens, (Medium
  11.   '      and High resolution).
  12.   '
  13.   '   -  The call to this procedure must pass the path by parameter!
  14.   '               Examples:
  15.   '                     sel_files("A:\")
  16.   '                     sel_files("C:\GFA\PROGS\MYSTUFF\")
  17.   '
  18.   '   -  The main program should have global or external variables with
  19.   '      these names and dimensions:
  20.   '
  21.   '            fil$(n)
  22.   '            fil_at(n)
  23.   '
  24.   '      Where 'n' is the maximum # of files allowed - a good number
  25.   '      to use is 175 becuase that is the whole screen filled up!
  26.   '      If there are more than 175 files in the path, then this code
  27.   '      will have to be altered to allow more!
  28.   '
  29.   '      fil$()      Holds the files in "no sort" order, starting with
  30.   '                  position 1.  0 is not used!
  31.   '
  32.   '      fil_at()    Holds the flags for the corresponding files in fil$(),
  33.   '                  A value of -1 is selected, 0 is de-selected.
  34.   '
  35.   ' NOTE :
  36.   '      If you do not have the above variables, please de-comment the
  37.   '      next two code lines!  (I can NOT guarantee this will let your
  38.   '      program use them after the user exits this procedure!)
  39.   '
  40.   '  DIM fil$(175)
  41.   '  DIM fil_at(175)
  42.   '
  43.   rez=XBIOS(4)
  44.   IF rez=0
  45.     PRINT
  46.     PRINT CHR$(7);"SEL_FILES only works in med & high res!"
  47.     PAUSE 100
  48.     GOTO skipall
  49.   ENDIF
  50.   t$="TEMP.DIR"
  51.   temp$=p$+t$
  52.   p$=p$+"*.*"
  53.   DIR p$ TO temp$
  54.   OPEN "I",#1,temp$
  55.   count=0
  56.   just$=SPACE$(12)
  57.   CLS
  58.   fcount=1
  59.   WHILE NOT EOF(#1)
  60.     INPUT #1,f$
  61.     IF f$=t$
  62.       GOTO skip
  63.     ENDIF
  64.     fil$(fcount)=f$
  65.     fil_at(fcount)=0      ! not selected
  66.     INC fcount
  67.     INC count
  68.     LSET just$=f$
  69.     IF count<7
  70.       IF count=1
  71.         PRINT "|";
  72.       ENDIF
  73.       PRINT just$;"|";
  74.     ELSE
  75.       count=1
  76.       PRINT
  77.       PRINT "|";just$;"|";
  78.     ENDIF
  79.     skip:
  80.   WEND
  81.   LINE 1,182*rez,639,182*rez
  82.   LINE 1,183*rez,639,183*rez
  83.   LINE 1,192*rez,639,192*rez
  84.   LINE 1,193*rez,639,193*rez
  85.   DEFTEXT 2,0,0,4
  86.   TEXT 192,199*rez,"FILENAME"
  87.   TEXT 300,199*rez,"CURRENT PATH"
  88.   TEXT 480,199*rez,"FILES SELECTED"
  89.   TEXT 6,189*rez,"RIGHT MOUSE BUTTON TO EXIT"
  90.   HIDEM
  91.   ' putm 96,4
  92.   SHOWM
  93.   ox=MOUSEX
  94.   oy=MOUSEY
  95.   REPEAT
  96.     MOUSE x,y,k
  97.     selx=INT((x/(13*8))+1)
  98.     sely=INT((y/(8*rez))+1)
  99.     sel=(((sely-1)*6)+selx)
  100.     IF k=1
  101.       IF fil$(sel)=""
  102.         PRINT CHR$(7);
  103.         GOTO skip2
  104.       ENDIF
  105.       IF fil_at(sel)=0
  106.         IF rez=2
  107.           PRINT CHR$(27)+"p";
  108.         ELSE
  109.           PRINT CHR$(27)+"b1";
  110.         ENDIF
  111.         fil_at(sel)=-1
  112.         INC fsel
  113.       ELSE
  114.         IF rez=2
  115.           PRINT CHR$(27)+"q";
  116.         ELSE
  117.           PRINT CHR$(27)+"b3";
  118.         ENDIF
  119.         fil_at(sel)=0
  120.         DEC fsel
  121.       ENDIF
  122.       PRINT AT(((selx-1)*13+2),sely);just$
  123.       force=-1
  124.       PAUSE 5
  125.     ENDIF
  126.     IF (NOT (selx=ox AND sely=oy))
  127.       force=-1
  128.     ENDIF
  129.     IF force=-1
  130.       force=0
  131.       LSET just$=fil$(sel)
  132.       IF rez=2
  133.         PRINT CHR$(27)+"q";
  134.       ELSE
  135.         PRINT CHR$(27)+"b3";
  136.       ENDIF
  137.       PRINT AT(22,24);"|";just$;"|";p$,"|  ";fsel;" ";
  138.       ox=selx
  139.       oy=sely
  140.       SHOWM
  141.     ENDIF
  142.     skip2:
  143.   UNTIL k=2
  144.   CLOSE #1
  145.   skipall:
  146. RETURN
  147.